Think of someone laughing so hard that their stomach muscles are tightening, making them look like they're being sewn together. This is where the "stitches" image comes from.
Here are some examples of how you could use the idiom:
* "The comedian's jokes had us in stitches. We couldn't stop laughing!"
* "The movie was hilarious! It had the whole audience in stitches."
* "The kids' silly antics had us in stitches all night."
It essentially means that the situation was very amusing and caused a lot of laughter.