The 23-year-old midfielder was left fighting for his life after suffering a cardiac arrest during an FA Cup tie against Tottenham Hotspur on March 17.
Fans in the stadium and those viewing on live television watched in horror as Muamba fell to the ground during the quarter-final clash that was abandoned.
Police were inundated with complaints as members of the public, former soccer player Stan Collymore among them, reported the student's comments.
Stacey, a Swansea University third-year biology undergraduate, was quickly tracked down and arrested.
Last week he admitted inciting racial hatred when he appeared at Swansea Magistrates' court and on Tuesday he was jailed for 56 days at the same court, the Press Association reported.
The first of Stacey's messages began with "LOL (laugh out loud) and said Muamba had died.
Several people took him to task for his views and he responded with a string of offensive comments aimed at other Twitter users.
Muamba remains in intensive care in hospital where his condition is described as serious but stable.
Stacey broke down as he was taken away in handcuffs to a holding cell beneath the court.
District Judge John Charles told him: "In my view there is no alternative to an immediate prison sentence."
The court heard that, when arrested, Stacey admitted his guilt and said he had been drunk at the time.
On the day in question, he had been out watching Wales's rugby grand slam victory and had drunk up to eight pints of beer.
Gareth jones, defending, said Stacey was completely ashamed of his behaviour.
"On the night in question his comments were vile - he admits that," Jones said.
Stacey has ambitions to become a forensic scientist.
That was now very unlikely, Jones said, and he would "pay dearly for the rest of his life" for what he had done.