Starting with the last question first, you were good enough to get round in one piece, so yes you're definitely good enough. Second from last question: I don't see how you've failed, so I can't see how you set yourself up for failure, you've now got the experience from your race to work on mentally before your next race (if you choose to do one, you don't have to). Third question: sometimes after a bad run/race anyone can get demotivated, but using different strategies most people can get through it. In terms of gaining confidence, I can only go by my own experience: I make sure I can do a distance on my own before entering for a race of the same distance, so I know I can get round and I have a reasonable idea of what sort of time to expect.
How long ago was the race? A lot of people get post race blues for the first few days after a race. Personally I find all motivation to do anything including running goes after the race, almost as if I've used up my quota in one go. Races don't suit everybody, and different size fields, average speed of the field, amounts of supporters etc can all make a difference to your race experience, so maybe try a few before you give up on them.
If you decide to do another race perhaps try to set more than one goal, ie.
Finish with no injuries, Finish in 55 min, Finish in 50 min, the idea is to be happy if you reach the lowest goal, pleased if you get the second and ecstatic if you get the third. They don't have to be time based, they can change up to the point you start the race and even while you're racing if you want.