Grenadier Guardsman Warren Butler, 19, of Carlisle, Cumbria, pleaded guilty to a charge of improper use of a communications network under section 127 of the Communications Act (2003).
The 19-year-old had posted on the social network site: "F****** LOL to that P*** found dead, One down many more to go."
Serena Edwards, prosecuting, told Basingstoke Magistrates' Court that Butler, who is based at Aldershot, Hampshire, had drunk about 10 bottles of Stella lager alone while his friends were on guard duty when he wrote the comment.
She said that after the comment went viral, Butler became concerned for the well-being of his family and contacted police.
Ms Edwards said that in interview, he told police he had attended EDL marches in the past and had a racist background.
She added that he also made comments about people of Eastern European backgrounds.
Ms Edwards said: "He said that he is from a racist background but not actively racist, he stated that if he knew the consequences he wouldn't have posted the comments."
Fabienne Macey, defending, said that the defendant, who was wearing full ceremonial uniform in his profile picture, deleted the comment and his Facebook account after he realised the impact of it, which had led to him receiving death threats.
She said: "He has grown up in a racist family, his father and grandfather were actively racist. He has been brought up not to like people of a different race and that is all he has known until being 19 years old and recently joining the Army.
"In the small community of Carlisle if he was to make such a comment, he doesn't think it would get the same reaction in that community, which gives an idea of the extent of the racism in that small community."
She added: "He has gone from a very sheltered insular background growing up to the professional Army job he has entered into. His maturity hasn't caught up with his job role otherwise he would know as an ambassador for the country he can never say what he has said."
Speaking in support of Butler, his platoon commander Captain James Stafford Allen said that the defendant had spent the past eight weeks under curfew with limited contact with his colleagues and he had been banned from accessing his mobile phone and the internet.
He said: "Prior to this incident Butler did have a clean slate within the Army and was following a promising career as a guardsman.
"Since the incident he has been kept in camp for eight weeks which in itself is a bit of a punishment. I have noticed him showing signs of remorse, he does truly regret what he has done."
He said the Army would consider Butler's position in its ranks following the sentencing.
Sentencing Butler to a 16-week prison sentence suspended for 18 months and 250 hours community service, District Judge Philip Gillibrand said: "Everybody has said what a despicable thing this was to do and I agree wholeheartedly.
"Those comments were in respect of a young child who had so tragically lost his life and in terms of the impact on the wider members of the family and also the impact it made across the nation - people were appalled at seeing this prejudice, completely unjustified, cruel and disrespectful."
He said that he was sparing the defendant a jail sentence in a bid to give him a chance to learn from his actions which he said had been a result of him being "brain-washed" by propaganda and by his upbringing.
He added that Butler had brought disgrace upon the British Army.
He said: "To post this Facebook entry with you standing there in your full ceremonial uniform was a great disgrace and brought the Army into tremendous disrepute."
Butler was also ordered to pay £85 court costs and a £80 victim surcharge and complete a 12-month supervision order which would include, diversity awareness and prejudice training as well as alcohol awareness.
Mikaeel's body was discovered in woodland in Fife, Scotland, on January 17 the day after he was reported missing from his home in the Drylaw area of Edinburgh.
His mother, Rosdeep Kular, 33, has been charged with his murder.
Speaking after the hearing, Kate Brown, chief prosecutor for the Crown Prosecution Service Wessex, said: "Warren Butler, a Grenadier Guardsman based in Aldershot thought that he could use social media to post a grossly offensive message and not face consequences.
"On 18 January, he posted on his Facebook account a racist comment, which callously referred to three-year-old Mikaeel Kular, who was found dead in Scotland the day before.
"The disappearance and the tragic discovery of the body of the little boy shocked many of us and it is therefore very difficult to understand how a 19-year-old is capable of making such cruel and disrespectful comments.
"Basingstoke Magistrates' Court heard today how, as soon as Butler posted this message he and his family received death threats. The chain of command of Butler's regiment was alerted and advised him to contact Hampshire Constabulary.
"Whilst he was interviewed by Hampshire Constabulary officers, Butler explained how he shared extreme rightwing ideology and that being racist was his opinion and that he did not think that his comments were bad.
"He also said to them that he only regretted the backlash it caused to his family.
"By posting his comment he made his family a target of death threats. He has now committed a criminal offence. By pleading guilty he has admitted full responsibility of his act.
"The CPS takes very seriously offences committed via social media. The DPP's guidance on cases involving social media makes clear that the threshold for prosecuting these cases is high and must be balanced against the right to freedom of speech.
"However, where there is sufficient evidence for this threshold to be met, and it is in the public interest to do so, we will vigorously prosecute."