First you need to destroy all the pillars that heal the ender dragon. I recommend crafting plenty of ladders to climb each piller. Once all pillars are destroyed, use a bow and arrow to attack the dragon. But when it gets closer to you l, use a diamond sword.
Also have diamond armor on. Usng enhancements on your armor, bow, and sword is a very wise decision.