To kill the Ender Dragon with a bed, you must set up a one-cycle platform. What this is basically placing a bed on top of a bedrock pillar with two obsidian blocks next to it.
Start by placing one bed on top of a bedrock pillar shrine in the end. After this place two blocks of obsidian on one of the sides of the bed - this is so when you explode the bed, it doesn't damage you. The video linked below will also show a great example of how your once cycle platform should look like.
That said, Once you have everything in place, you will be able to kill the Dragon by trying to using the bed. But before doing anything, make sure to have at least seven to eight beds, and maybe a few more in your inventory in case you mess up.
When you got all of that, you can kill the ender dragon by exploding the beds by using them at the right time. This time will be right when the ender dragon swoops down over the bed, but to get the timing right, you should probably use it a little before his head is about to fly over the bed.
You will also need to target the middle part of the dragon's head, as this is where it will take the most damage. Luckily you can do this if you wait for the right moment, but if you need some extra help, check out the awesome guide by Josh The Squash that will be linked above.