badsi
Although there may be a need for occupational therapy - and you should explore that. If it is just a lack of attention (or possibly stamina) there are a few things you can do at home.
My girls both went through stages of Y2 (DD2 currently in Y2 and still in this stage actually) of being labelled as having 'messy handwriting'. With DD1 it was further complicated by being left handed so smudging a lot of her work.
We work on it at home in several ways (partly because we have so little actual writing homework to do at home):
Encourage writing (post cards, thank you cards, invitations, little letters to friends, etc...) as much as you can. Try to get them to write more than Happy Birthday or Thank you. Encourage them to write a whole sentence thanking someone for a gift or wonderful day out.
Encourage practice. I bought both DDs grown up decorated diaries which they could use to practice their handwriting and signatures. DD1 absolutely filled this with a myriad of different writing styles and all that practice helped improve her pencil control I think. She certainly has settled into really lovely penmanship now (Y4).
Encourage labelling of pictures for people outside the family - I use the old trick - Oh Aunty X might not remember the story of Sleeping Beauty - best label the characters so she understands and maybe write a little about what you've drawn here.
Encourage drawing/ colouring in - all good for building hand/ arm strength. I highly recommend the Crayola twistables coloured pencils - and going for more tricky colouring books like geometric shapes (e.g. www.amazon.co.uk/s/ref=nb_sb_ss_i_0_13?url=search-alias%3Daps&field-keywords=geometric+colouring+book&sprefix=geometric+col%2Caps%2C139 - frankly also useful for travelling/ waiting for doctor or dentist/ etc...
For certain tasks - really insist on good penmanship - so for example writing out spelling words. Say they can have 5 minutes TV time for each line of words/ sentence using spelling words which is clearly written and letters are all at correct heights.
Finally - if the issue is the height of letters (and sorting that out) - try and locate some lined paper with a hatched line in the middle or try a workbook (like this www.amazon.co.uk/Collins-Easy-Learning-Handwriting-Practice/dp/0007301030/ref=sr_1_fkmr2_1?ie=UTF8&qid=1327492284&sr=8-1-fkmr2. I often use a ruler and lightly pencil in the hatched half-way line to help control size of letters. Still losing the battle with height of 'w' for DD2 - but we just keep at it.
Also do remember that eventually they will get the hang of it. As some have posted there is a lot of co-ordination to learn. It isn't always instantly picked up.
Hang in there - keep practicing - but keep it short, sweet and sneaky!