This paper explores whether human cognition can be explained by principled adaptation to the statistical structure of real-world environments. We develop a novel learning algorithm, Ecologically Rational Meta-Learning Inference (ERMI), by leveraging a large-scale language model that generates ecologically relevant cognitive tasks and meta-learning to derive rational models optimized for these environments. ERMI internalizes the statistical regularities of naturalistic problem spaces and flexibly adapts to new situations without handcrafted heuristics or explicit parameter updates. Across 15 experiments (including function learning, category learning, and decision-making), it captures human behavior and outperforms several existing cognitive models in trial-by-trial predictions. This suggests that a significant portion of human cognition may reflect adaptive alignment with the ecological structure of problems encountered in everyday life.