Preheat oven to 350. In a large skillet, melt the butter over medium heat. Add the onion and garlic and saute until the onion is translucent and the garlic is fragrant. Remove from heat. Add the thawed hash browns, sour cream, soup, cheese, salt, and diced pepper (if using) and combine well. Add additional salt and pepper if necessary.
Spread the mixture into a 9×13″ (or similar) dish and bake for 50-60 minutes or until the casserole is hot in the center and the cheese is bubbly throughout.