If I was born as a dirt-poor peasant in the medieval ages, what were my chances of getting an education and joining the clergy? Maybe becoming a monk or joining the Church?
Medieval peasants could absolutely join the clergy. High-level ecclesiastical positions - bishops, abbots/abbesses of important monasteries (Cluny), etc. - were typically reserved for elites, but were not necessarily exclusive to them. This is especially true for nuns, the only real position available to women in the church: many of the most important female monasteries were founded by royal widows, or king's sisters, and aside from the necessary female servants would have attracted equally noble ladies as novices. (In Byzantium women could also become deaconesses, to supervise women's [naked] baptisms instead of men, but they're already fading out by the eleventh century.) Lower positions - parish priests, deacons, monks, canons, etc. - were much more open to the average man, simply because there were a lot more of them: for every one bishop you might have, say, a hundred priests, for every priest a couple of deacons, and so on. Even serfs (of the church or of a local lord) could be made priests - theoretically this required them to be freed beforehand, but they weren't always.
Education, however, is a different question. If you learned to read in the Middle Ages you almost certainly learned to do so on Scripture (most likely on the Psalms, at least in Byzantium), whether or not you were planning on a church career. But the literate population at any given time was extremely small. Most people could likely only sign their name (or write an X), or recognize a few important words or abbreviations ("inn," "notary," "king," "Jesus," etc.), if even that much. A certain standard of education was definitely expected of clerics - monastic rules, for example, usually specify that monks have a given amount of "reading time" per day, and priests should logically be able to at least give a coherent homily - but they didn't always live up to that standard. Medieval literature, especially once people start writing in vernacular (non-Latin) languages, is full of stories of idiotic, illiterate priests. Sometimes this is even true of very high-level positions: some Patriarchs of Constantinople are alleged to have barely been able to read and write. Monks occasionally prided themselves on a lack of education, which they thought of as an excessively worldly attachment. All a monk really needed to know was the Psalter, which many monks (even highly educated ones) knew by heart. At the same time, though, most books are heavily concentrated in (especially monastic) libraries. Some of the most educated and intelligent medievals were ecclesiastics (even including women, like Hildegard of Bingen). If you entered a monastery as an adult, you may be taught to read so you can learn the Psalms and read at Mass, but not necessarily. "Lay" brothers (as opposed to ordained "choir" monks) were usually taken in mostly as laborers, to handle the immense amount of physical labor needed to maintain a monastery's land and keep the foundation running, so teaching them to read was thought of as kind of a waste of time when they could just follow along with the choir monks or even leave the bulk of the theological work to them. But joining a monastery wasn't as easy as simply moving oneself in - foundations could require a kind of "entrance fee" in the form of land, goods, or cash, and if you couldn't live up to the abbot's standards you very well could get kicked out.
All of that said, though, a monastery was probably the best bet for acquiring a medieval education. Cathedral schools definitely existed, but they were generally meant specifically to prepare boys for ecclesiastical careers (though arguably this is what serious monastic education was meant to do, too). Most monks, even lay ones, would have been expected to know at least how to read enough to memorize the texts of the Divine Office. Once they acquired that skill, they would have the best chance of studying "rare" materials unable most everywhere else.
Sources:
The overwhelming number of secular clergy, that is, men not bound by monastic or mendicant vows, were drawn from the peasant or merchant classes. It’s important to bear in mind three things. First, few priests were well-to-do. Only those who were beneficed, that is, who held title to the income from their parish through tithes and land there assigned to the church, were apt to have a decent income and even that was no guarantee if the parish was a poor one. In England, for example, there were thousands of unbeneficed priests who eked out a living as assistant parish priests, private chaplains, or chantry priests (who paid by private patrons to say regular masses for departed family members). In rare instances, a priest with a peasant background could rise spectacularly, the best case being Robert Grosseteste (d. 1253), whose parents were peasants (maybe even serfs—I can’t recall). He became the Bishop of Lincoln and a prominent Oxford proto-scientist, known especially for his study of optics.
Second, it’s equally important to remember that not all peasants were dirt poor. There were quite prosperous peasants who had managed to acquire large holdings of land. Boys from these families could be groomed for the priesthood, probably chosen for their piety, aptitude, or their interest in church matters. But boys lower down the peasant social scale, even serfs with proper dispensation as arivderestellle’s excellent account notes, could also be ordained just so long as they could prove that they had some means of support once they were ordained.
Third, only a bare minimum of literacy was required for ordination, usually just enough to be able to recite the Mass and other liturgical services. Even that low standard might be beyond reach depending on when and where we’re talking about. The medieval church never established a uniform standard of education for priests and certainly never managed to create the seminaries to train priests that the Council of Trent built in later years of the 16th century. In the Middle Ages, education for the secular clergy was hit or miss. From the 13th century on, several popes took stabs at encouraging university training for priests but ultimately only the barest handful of secular clergy had such higher education training and if they did it was not geared toward pastoral care of parishioners (no classes per se, for instance, in sermon-making). Typically, boys who showed aptitude for it got rudimentary training from grammar schools or from local tutoring in their village, usually from the village priest (especially chantry priests who, at least in England, were prone to setting up ad hoc village schools). Again in England, there was a special office of the “holy water clerk” (aquabaiulus). This clerk was assigned the duty of sprinkling parishioners and their houses with holy water. (This is the job Absolon in Chaucer’s “Miller’s Tale” has.) It had a small income attached to it which was specifically intended to go toward the clerk’s grammar school education.
TL;DR: Peasants could be priests, especially priests who worked in parishes.
Source: Off the top of my head, but a useful summary for make-up of the English parish clergy would be Peter Heath, The English Parish Clergy on the Eve of the Reformation.