I am moving from Malaysia to the US, and planning to bring my desktop computer with me. I plan to pack it in my checked-in luggage. Will the computer risk being damaged? Any precaution should I take to reduce this risk? Will there be any trouble with the airline or immigration about bringing computer?
There's no problem with doing this. However, a couple of things I'd consider doing to protect it:
The airline should have no problem at all. I've done this myself with many airlines, and I'm sure many people do it every day. It's only if you take it as carry-on that they'll want you to take it out of your bag for extra screening. If however you want to be certain, check with the check-in agent at the desk, but they'll be fine with it, I'm sure.
In general, you can bring a desktop computer as checkin baggage, even on international flights, but there is a risk of damage you should consider. They tend to be so commonplace of a device that are well-recognized and tend not to arouse suspicion.
Anecdotally, I was part of a group trip to Costa Rica (from the US) where we brought approximately 30-40 used desktop computers, complete with old fashioned glass CRT monitors as checkin luggage to donate to worthwhile organizations in Costa Rica. Of those, approximately 5-6 CPUs were damaged and a slightly higher percent of the monitors. The computers were wrapped in a couple layers of bubble wrap (the kind for with the larger 1"/2cm bubbles), inside a soft shell duffel bag, probably not as ideally wrapped as I would wrap my own personally computer. So, if my experience is in any way typical, odds are good, but far from perfect, that your PC will arrive undamaged. Most of the time, luggage will arrive in good condition, however, luggage could get dropped or fall off a baggage cart, for example, and even well packed, there's a risk of damage.
Providing adequate packaging, such as the original CPU's box with styrofoam inserts, is one of the best ways to minimize damage. New PCs are shipped to their destination in such packaging all the time without incident. Keep in mind, depending on the baggage policies of your airline, there may or may not be restrictions on using cardboard boxes as checkin luggage. If there are prohibitions, placing the entire box in an inexpensive large soft-sided duffel bag with handles will usually suffice. Alternately, a hard-shelled suitcase, filled with foam or other absorbant material (preferably ESD foam) around the PC would be the next-best alternative. Keep in mind your packaging may need to be opened if your bag or box is randomly selected for additional screening, so don't make the packaging so intricate or complex or not-reasealable that a luggage inspector would not be able to put the protective packaging back how you intend if it is subjected to additional screening. If they do have to cut packing tape, typically that is replaced with new packing tape by the screeners. Zip ties on the other hand, for example, are not replaced if cut by screeners.
The most likely component to suffer damage from rough handling is your hard drive, especially if you have a typical desktop computer harddrive in your computer. Desktop computer harddrives are significantly more fragile than laptop harddrives, and can be damaged by jostling and impact, making the entire drive unreadable. So possible improvements could vary from replacing your 3 1/2" hard drive with a 2 1/2" laptop hard drive (and using conversion rails or a mounting kit to attach the hard drive in your case), to replacing a standard hard drive with a solid state hard drive (bonus points: they're super fast), or backing up any/all critical files to a recovery medium such as DVD or USB flash drive or internet location, such that you could restore your data should your hard drive become damaged from the journey. Carrying the hard drive as a carry-on item (as suggested by Mark Mayo) is not a bad idea and reduces the risk of someone other than yourself handling the item roughly, but keep in mind that a typical non-solid state desktop hard drive is still rather delicate and there is a risk you'll go to plug it back in and it just...won't work. So absolutely bring back ups of your data, or back up important data online somewhere before your trip.
It is possible some other component of the computer (motherboard, video card, etc). could get damaged from the entire case being dropped, so if that were to happen you might have to replace something (or several parts), but that is slightly less common than hard drive damage.
Make sure everything in the PC is seated securely, screwed in, and there are no loose wires hanging precariously or loosely. Excess lengths of cables should be replaced, bundled or tied to mounts in the case or otherwise secured so that they will not be bumping into other components inside the case. Your whole PC could be carried upside down or sideways leading to things bumping where they wouldn't normally on your desk.
Additionally, to minimize the risk of damage from electro-static discharge (ESD), wrapping the entire PC in a large ESD bag or ESD foam would be another precaution you could take. Consider that brand new hard drives and motherboards are almost always wrapped in such a protective container before being shipped to stores.
You can pack your computer as a checked bag, Mark Mayo's answer covers how to do so pretty well.
But I would highly recommend against packing a desktop computer. With all the wires and whatnot it will look "suspicious" to security personnel, and they'll almost certainly go through your bag (likely not repacking it with any care).
I would recommend shipping the computer to the destination, even a service as simple as the postal system. It will undoubtedly take longer to arrive, but if properly packed will arrive in tact.
I've worked with computers for half of my life. Shipping has never failed me yet. Overzealous security personnel, well I've got a few stories about them already...